<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    <meta content='width=device-width, initial-scale=1.0' name='viewport'>
    <meta content='' name='description'>
    <meta content='Nils Nordman' name='author'>
    <link href='/images/howl.png' rel='shortcut icon'>
    <title>Howl :: Spec - howl.ui.Cursor</title>
    <link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/syntax.css" media="screen" rel="stylesheet" type="text/css" />
    <link href="/stylesheets/howl.css" media="screen" rel="stylesheet" type="text/css" />
    <link href='//fonts.googleapis.com/css?family=Josefin+Slab' rel='stylesheet' type='text/css'>
    <link href='//fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
  </head>
  <body class='doc doc_spec doc_spec_ui doc_spec_ui_cursor_spec'>
    <div class='container'>
      <div class='masthead'>
        <ul class='nav nav-pills'>
          <li>
            <a href='/'>
              <span class='glyphicon glyphicon-home'></span>
              Home
            </a>
          </li>
          <li>
            <a href='/doc/'>
              <span class='glyphicon glyphicon-book'></span>
              Documentation
            </a>
          </li>
          <li>
            <a href='/blog/'>
              <span class='glyphicon glyphicon-bullhorn'></span>
              Blog
            </a>
          </li>
          <li>
            <a href='/contact.html'>
              <span class='glyphicon glyphicon-inbox'></span>
              Contact
            </a>
          </li>
        </ul>
      </div>
      <ol class="breadcrumb"><li><a href="/">Home</a></li><li><a href='../../'>Howl 0.3 Documentation</a></li><li>Spec</li><li>Ui</li><li>Spec - howl.ui.Cursor</li></ol>
      <div class="spec-group spec-group-1">&#x000A;&#x000A;<h1 id="howl.ui.cursor">howl.ui.Cursor</h1>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Buffer</span><span class="w"> </span><span class="p">{}</span><span class="w">&#x000A;</span><span class="n">editor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">Editor</span><span class="w"> </span><span class="n">buffer</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">cursor</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;&#x000A;</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">text</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;  </span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">false</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id=".at_end_of_line-returns-true-if-cursor-is-at-the-end-of-the-line">.at_end_of_line returns true if cursor is at the end of the line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_false</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_line</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">15</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_line</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id=".at_start_of_line-returns-true-if-cursor-is-at-the-start-of-the-line">.at_start_of_line returns true if cursor is at the start of the line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_start_of_line</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_start_of_line</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id=".at_end_of_file-returns-true-if-cursor-is-at-the-end-of-the-buffer">.at_end_of_file returns true if cursor is at the end of the buffer</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_false</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_file</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">eof</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">at_end_of_file</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="move_to(line,-column)-moves-the-cursor-to-the-specified-line-and-column">move_to(line, column) moves the cursor to the specified line and column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello\nworld'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">move_to</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">8</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="down!-moves-the-cursor-one-line-down,-respecting-the-current-column">down! moves the cursor one line down, respecting the current column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">down</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="up!-moves-the-cursor-one-line-up,-respecting-the-current-column">up! moves the cursor one line up, respecting the current column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">up</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="right!-moves-the-cursor-one-char-right">right! moves the cursor one char right</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="left!-moves-the-cursor-one-char-left">left! moves the cursor one char left</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">left</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span></code></pre>&#x000A;&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".style">.style</h2>&#x000A;&#x000A;<h4 id="is-&quot;line&quot;-by-default">is &quot;line&quot; by default</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'line'</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">style</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="raises-an-error-if-set-to-anything-else-than-&quot;block&quot;-or-&quot;line&quot;">raises an error if set to anything else than &quot;block&quot; or &quot;line&quot;</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">style</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'block'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">style</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'line'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">raises</span><span class="w"> </span><span class="s1">'foo'</span><span class="p">,</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">style</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo'</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".pos">.pos</h2>&#x000A;&#x000A;<h4 id="reading-returns-the-current-character-position-in-one-based-index">reading returns the current character position in one based index</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">editor</span><span class="p">.</span><span class="n">sci</span><span class="o">\</span><span class="n">goto_pos</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="c1">-- raw zero-based sci access, really at 'e'</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="setting-sets-the-current-position">setting sets the current position</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="setting-adjusts-the-selection-if-it-is-persistent">setting adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">selection</span><span class="o">\</span><span class="n">set</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="out-of-bounds-values-are-automatically-corrected">out-of-bounds values are automatically corrected</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">0</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">math.huge</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".line">.line</h2>&#x000A;&#x000A;<h4 id="returns-the-current-line">returns the current line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="setting-moves-the-cursor-to-the-first-column-of-the-specified-line">setting moves the cursor to the first column of the specified line</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="p">,</span><span class="w"> </span><span class="mi">16</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="assignment-adjusts-out-of-bounds-values-automatically">assignment adjusts out-of-bounds values automatically</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="o">-</span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">100</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="n">buffer</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="assignment-adjusts-the-selection-if-it-is-persistent">assignment adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\n'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column">.column</h2>&#x000A;&#x000A;<h4 id="returns-the-current-column">returns the current column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column-=-&lt;nr&gt;">.column = &lt;nr&gt;</h2>&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-specified-column">moves the cursor to the specified column</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="takes-tabs-into-account">takes tabs into account</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;</span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text after'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="adjusts-the-selection-if-it-is-persistent">adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">5</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column_index">.column_index</h2>&#x000A;&#x000A;<h4 id="returns-the-real-column-index-for-the-current-line-disregarding-tabs">returns the real column index for the current line disregarding tabs</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text'</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;  </span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span><span class="w">&#x000A;  </span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="returns-the-column-index-as-a-character-offset">returns the column index as a character offset</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö\nåäö'</span><span class="w">&#x000A;  </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">6</span><span class="w">&#x000A;  </span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="adjusts-the-selection-if-it-is-persistent">adjusts the selection if it is persistent</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">selection</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'åä'</span><span class="p">,</span><span class="w"> </span><span class="n">selection</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h2 id=".column_index-=-&lt;nr&gt;">.column_index = &lt;nr&gt;</h2>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">config</span><span class="p">.</span><span class="n">tab_width</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">4</span><span class="w">&#x000A;  </span><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'\tsome text after'</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="moves-the-cursor-to-the-specified-column-index">moves the cursor to the specified column index</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">5</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column</span></code></pre>&#x000A;&#x000A;&#x000A;<h4 id="treats-&lt;nr&gt;-as-a-character-offset">treats &lt;nr&gt; as a character offset</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">buffer</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'åäö\nåäö'</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">column_index</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when passing true for extended_selection to movement commands)</span></h3>&#x000A;&#x000A;<h4 id="the-selection-is-extended-along-with-moving-the-cursor">the selection is extended along with moving the cursor</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">sel</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">right</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'L'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">down</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\nA'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">left</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\n'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">up</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">is_true</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">empty</span></code></pre>&#x000A;&#x000A;</div>&#x000A;<div class="spec-group spec-group-2">&#x000A;&#x000A;<h3 id=""><span class="arg-list">(when the editor selection is marked as persistent)</span></h3>&#x000A;&#x000A;<h4 id="the-selection-is-extended-along-with-moving-the-cursor">the selection is extended along with moving the cursor</h4>&#x000A;&#x000A;<pre class="highlight moonscript"><code><span class="n">sel</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">editor</span><span class="p">.</span><span class="n">selection</span><span class="w">&#x000A;</span><span class="n">sel</span><span class="p">.</span><span class="n">persistent</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">true</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">pos</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="o">\</span><span class="n">right</span><span class="o">!</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'L'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span><span class="w">&#x000A;</span><span class="n">cursor</span><span class="p">.</span><span class="n">line</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">2</span><span class="w">&#x000A;</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="s1">'Liñe 1 ʘf tƏxt\n'</span><span class="p">,</span><span class="w"> </span><span class="n">sel</span><span class="p">.</span><span class="n">text</span></code></pre>&#x000A;&#x000A;</div>&#x000A;</div>
      <div class='footer text-muted'>
        <a href='/'>
          <img width="50" height="50" class="footer-logo" src="/images/howl.png" />
        </a>
        <div class='footer-follow'>
          <p>
            <a class='twitter-follow-button' data-lang='en' data-show-count='false' href='https://twitter.com/howleditor' rel='me'>
              Follow @howleditor
            </a>
          </p>
          <p>
            <a class='twitter-share-button' data-count='none' data-hashtags='howleditor' data-lang='en' data-text='The Howl Editor, a general purpose, light-weight customizable editor.' data-url='http://howl.io' href='https://twitter.com/share'>
              Tweet
            </a>
          </p>
        </div>
        <div class='footer-blurb'>
          <div>The Howl editor.</div>
          <div>
            Copyright 2012-2015
            <a class='alert-link' href='https://github.com/nilnor/howl/contributors'>
              The Howl Developers.
            </a>
          </div>
        </div>
      </div>
    </div>
    <script>
      <!-- / GA -->
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      ga('create', 'UA-45283282-1', 'howl.io');
      ga('send', 'pageview');
      <!-- / Twitter -->
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
      if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
      js.src="//platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
    </script>
  </body>
</html>
